import {
  createApp,
  nextTick
} from 'vue'
import App from './App.vue'
import pinia from './store/index'
import router from './router'
import ElementPlus from 'element-plus'
// element中文包引入
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'dayjs/locale/zh-cn'
// 解决 ElTable 自动宽度高度导致的「ResizeObserver loop limit exceeded」问题
const debounce = (fn, delay) => {
  let timer = null;
  return function () {
    let context = this;
    let args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  }
}
const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
}
import piniaPluginPersist from 'pinia-plugin-persist'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import "./global.css";
import "./css/iconFont.css";
import formItem from './components/public/formItem.js'
import formItemJson from './components/public/formItemJson.js'
import FormLayout from './components/public/FormLayout.vue'
import {
  globalColor
} from "@/store/pinia";

import basicForm from '@/views/commonComponents/drag/formItem/basicFormStyle.vue'
import Table from '@/components/table/Table'
import Dialog from '@/components/dialog/dialog.vue'
// 图标组件
import IconFont from '@/components/icon/IconFont'
// 图标js
import '@/assets/iconFont/iconFont.js';
import * as echarts from 'echarts'
import util from './util'
const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
import { getVue } from '@/hooks/directive/directive.js'
app.config.globalProperties.$echarts = echarts
app.config.globalProperties.$util = util
app.component('g-formItem', formItem)
app.component('json-form', formItemJson)
app.component('basic-form', basicForm)
app.component('my-dialog', Dialog)
app.component('my-table', Table)
app.component('SvgIcon', IconFont);
app.component('form-layout', FormLayout);
app.use(pinia.use(piniaPluginPersist)).use(router).use(ElementPlus, {
  locale: zhCn,
}).mount('#app')
getVue(app)